class ListNode:
    def __init__(self, x):
        self.val = x
        self.next = None

# sentry 1 1 1 1 1
class Solution:
    def deleteDuplication(self, pHead):
        # write code here
        number_map = {}
        temp_node = pHead
        while temp_node is not None:
            if temp_node.val not in number_map:
                number_map[temp_node.val] = 1
            else:
                number_map[temp_node.val] += 1
            temp_node = temp_node.next
        flag_def = False
        head_node = pHead
        sentry = ListNode(0)
        sentry.next = pHead
        pre_node = sentry
        temp_node = pHead
        while temp_node is not None:
            if number_map[temp_node.val] > 1:
                pre_node.next = temp_node.next
            else:
                if flag_def is False:
                    head_node = temp_node
                    flag_def = True
                pre_node = temp_node
            temp_node = temp_node.next
        if pre_node is sentry:
            return None
        return head_node
